#!/usr/bin/env python3
# -*- coding:utf-8 -*-
###
# File: var_args.py
# -----
# Description:  函数的参数
# -----
# Created  By: Aim 2020-01-29 16:31:30
# Modified By: Aim 2020-01-29 18:19:12
# -----
# HISTORY:
# Date      	By	Comments
# ----------	---	----------------------------------------------------------
###


def power(x, n=2):
    s = 1
    while n > 0:
        n = n-1
        s = s * x
    return s


# print(power(5))

def enroll(name, gender, age=6, city='Beijing'):
    print('name:', name)
    print('gender:', gender)
    print('age:', age)
    print('city:', city)

# enroll('Sarah', 'F')
# enroll('Bob', 'M', 7)

# enroll('Aixing', 'L', city='Luqiao')

# 定义默认参数要牢记一点：默认参数必须指向不变对象！


def add_end(L=None):
    if L is None:
        L = []
    L.append('END')
    return L

# print(add_end([1,2,3]))
# print(add_end())
# print(add_end())

# 可变参数


def calc(*numbers):
    sum = 0
    for n in numbers:
        sum = sum + n * ｎ
    return sum


# print(calc(1, 2, 3))
# print(calc())

# nums = [1,2,3]
# print(calc(*nums))

# 关键字参数

def person(name, age, **kw):
    print('name:', name, 'age:', age, 'other:', kw)

person('Jack', 24, city='Beijing', addr='Chaoyange', zipcode=123456)